package com.zyy.joseata.config;

import com.zyy.joseata.interceptor.TransManagerInterceptor;
import com.zyy.joseata.socket.SocketClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @author zhangyy
 */
@Configuration
public class TransManagerConfig {

    @Resource
    private SocketClient socketClient;

    @Bean
    public PlatformTransactionManager transactionManager(DataSource dataSource){
        TransManagerInterceptor transManagerInterceptor = new TransManagerInterceptor(dataSource);
        transManagerInterceptor.setSocketClient(socketClient);
        return transManagerInterceptor;
    }
}
